// src/services/roleUser.ts
import {request} from '@umijs/max';

// 获取角色列表 (复用)
export async function getRoleList(params: any) {
    return request('/best-live-boot/sys/role/list', {
        method: 'GET',
        params,
    });
}

// 删除单个角色 (复用)
export async function deleteRole(params: { id: number }) {
    return request('/best-live-boot/sys/role/delete', {
        method: 'DELETE',
        params,
    });
}

// 获取角色绑定用户的情况
export async function queryRoleBindCount(params: any) {
    return request('/best-live-boot/sys/role/queryRoleBindCount', {
        method: 'GET',
        params,
    });
}

// 获取指定角色下的用户列表
export async function getUserListByRole(params: any) {
    return request('/best-live-boot/sys/user/queryUserListByRole', {
        method: 'GET',
        params,
    });
}

// 获取指定用户下的角色列表
export async function getRoleListByUser(params: any) {
    return request('/best-live-boot/sys/role/queryRoleListByUser', {
        method: 'GET',
        params,
    });
}

// 为用户添加角色
export async function addUserRole(data: { userId: number; roleId: number }) {
    return request('/best-live-boot/sys/role/addSysUserRole', {
        method: 'POST',
        data,
    });
}

// 删除用户角色关联 (单个)
export async function deleteUserRole(params: {
    userId: number;
    roleId: number;
}) {
    return request('/best-live-boot/sys/role/deleteUserRole', {
        method: 'DELETE',
        params,
    });
}

// 批量删除用户角色关联
export async function deleteUserRoleBatch(params: {
    userIds: number[];
    roleId: number;
}) {
    return request('/best-live-boot/sys/role/deleteUserRoleBatch', {
        method: 'DELETE',
        params,
    });
}

// 获取所有用户 (用于选择用户)
export async function getAllUsers(params: any) {
    return request('/best-live-boot/sys/user/queryall', {
        method: 'GET',
        params,
    });
}
